home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*------------------------*
- * CPPFIC3.C *
- * FILE MANAGER *
- * Recording of the saves *
- * Changes in Help file *
- *------------------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
- # include <dir.h>
- # include <string.h>
- # include <alloc.h>
- # include <mem.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,xm,y,ym,z,menu0,menu1,return1;
- extern int colour1,colour2,colour3,colour4,colour5,nbdisk,return2,return3,recording;
- extern int lline,linemax,choice,modif,pfdiv,pfserv,pfhelp,returning;
- extern unsigned int ref,nbref,nbrep;
- extern long dep,depdiv,dephelp;
- extern unsigned long nbbytes;
- extern unsigned char c0,c1,trashcan[],path[],nc1[],trashret[],filedir[];
- extern unsigned char work[],record[],saverep[];
- extern struct ffblk ffblk;
-
- /*-------------------*
- * BLANK LINE 25 *
- *-------------------*/
- void blank_line_25()
- {
- textattr(colour1); gotoxy(1,25);
- cputs(" ");
- }
- /*-----------------------------------*
- * CONFIRM RECORDING DIRECTORY *
- *-----------------------------------*/
- int confirm_recording_directory()
- {
- /* Display the selected directory */
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Record dir= ");
- gotoxy(13,25); cputs(record);
- /* Ask the confirmation of the destination */
- l=message(" Recording to"," the directory"," at the bottom"," Confirm Please"," Yes or No Y/N");
- if(l==-1) return(-1);
- if(l==34) return(1);
- if((l==100)&&(ym==21)&&(xm>51)&&(xm<57)) return(1);
- /* If we do not agree we can type another directory */
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Record dir= ");
- strcpy(trashcan,record);
- l=get_or_change_a_word(13,25,64);
- if(l==1){
- /* We confirmed a directory */
- strcpy(record,trashret); return(1);
- }
- else return(0);
- }
- /*-------------------------------*
- * FULL RECORDING PATH *
- *-------------------------------*/
- int full_recording_path()
- {
- strcpy(saverep,record); j=strlen(saverep);
- /* Cut the spaces at the end of the word */
- for(i=j; i>0; i--){
- c1=saverep[i];
- if((c1==0x20)||(c1==0x00)) saverep[i]=0x00;
- else break;
- }
- /* Create a path by adding the date to the path name */
- get_date_text_format(); nc1[2]=0x00;
- nc1[0]=trashcan[0]; nc1[1]=trashcan[1];
- strcat(saverep,nc1);
- nc1[0]=trashcan[3]; nc1[1]=trashcan[4];
- strcat(saverep,nc1);
- nc1[0]=trashcan[6]; nc1[1]=trashcan[7];
- strcat(saverep,nc1); c0=65;
- while(1){
- nc1[0]=c0; nc1[1]=0x00;
- strcpy(filedir,saverep); strcat(filedir,nc1);
- /* Check the name to be sure that this directory does not exist yet */
- strcat(filedir,"\\*.*");
- j=findfirst(filedir,&ffblk,0x37);
- if(j==-1){
- /* It does not exist yet, then add the suffix to the path */
- strcat(saverep,nc1); break;
- }
- /* Else increment the indice B, C, D, etc. (last : Z) */
- c0++;
- if(c0>90){
- /* We are after Z */
- warning(" Too many files"," in this directory"," Enter another"," directory name"," Click or press a key");
- break;
- }
- }
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Record dir= ");
- gotoxy(13,25); cputs(saverep);
- l=message(" Recording to"," the directory"," at the bottom"," Confirm Please"," Yes or No Y/N");
- if(l==-1) return(-1);
- if(l==34) return(1);
- if((l==100)&&(ym==21)&&(xm>51)&&(xm<57)) return(1);
- /* If we do not agree we can type another directory */
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Record dir= ");
- strcpy(trashcan,saverep);
- l=get_or_change_a_word(13,25,64);
- if(l==1){
- /* We confirmed a directory */
- strcpy(saverep,trashret); return(1);
- }
- else return(0);
- }
- /*------------------------------*
- * FILE RECORDING *
- * Function 7 of the Files menu *
- *------------------------------*/
- void file_recording()
- {
- /* Active the variable which confirms the recording */
- recording=1;
- returning=confirm_recording_directory();
- if(returning<1) return;
- returning=full_recording_path();
- if(returning<1) return;
- /* If everything is OK, then create the directory */
- returning=mkdir(saverep);
- if(returning<0) return;
- /* Now, the recording is made */
- directory_change();
- }
- /*--------------------------------*
- * CREATE FILE FOR ON-LINE HELP *
- *--------------------------------*/
- void create_on_line_help_file()
- {
- FILE *fileread,*filewrite;
- /* As we do not want to take too much place on the drive, */
- /* we copy directly in the HELP.FIC file */
- l=2;
- if((fileread=fopen("HELP.TXT","r"))==NULL){
- warning(" Cannot open"," the file HELP.TXT"," for reading"," Press a key"," or click");
- return;
- }
- if((filewrite=fopen("HELP.FIC","wb"))==NULL){
- warning(" Cannot open"," the file HELP.FIC"," for an update"," Press a key"," or click");
- return;
- }
- while((fread(trashcan,1,l,fileread))==2){
- m=0;
- for(x=0; x<l; x++){
- c0=trashcan[x];
- if(c0!=0x0d){
- if(c0!=0x0a){
- trashret[m]=c0;
- m++;
- }
- }
- }
- fwrite(trashret,1,m,filewrite);
- }
- fwrite(trashret,1,m,filewrite);
- fclose(fileread); fclose(filewrite);
- }
- /* End of Module *//*------------------------*/
-